import { request } from "@/utils/http";
import type {
  Departments,
  HospitalScheduleResponse,
  HospitalShow,
  ProvinceItems,
  ReqGetHospitalListParams,
  ReqGetHospitaScheduleParams,
  ReqGetScheduleRuleParams,
  ReqGetScheduleRuleResponse,
  ReqHospitalListResponse,
} from "./model/hospitalListTypes";

/**
 * 获取医院列表数据
 * @param param0 对象 请求的参数结构
 * @returns Promise<ReqHospitalListResponse>
 */
export function reqGetHospitalList({
  page,
  limit,
  ...args
}: ReqGetHospitalListParams) {
  return request.get<any, ReqHospitalListResponse>(
    `/admin/hosp/hospital/${page}/${limit}`,
    {
      params: args,
    }
  );
}

/**
 * 获取省份的信息
 * @returns Promise<ProvinceItems>
 */
export function reqGetProvinces(){
  return request.get<any, ProvinceItems>('/admin/cmn/dict/findByDictCode/province');
}

/**
 * 根据 id 获取该区域下的子集区域
 * @param parentId 区域的 ID
 * @returns Promise<ProvinceItems>
 */
export function reqGetCityOrDistrict(parentId: number){
  return request.get<any, ProvinceItems>(`/admin/cmn/dict/findByParentId/${parentId}`)
}

/**
 * 获取医院类型的数据
 * @returns Promise<ProvinceItems>
 */
export function reqGetHospitalTypes(){
  return request.get<any, ProvinceItems>('/admin/cmn/dict/findByParentId/10000');
}

/**
 * 根据 id 获取医院的详细内容
 * @param id  医院的 id 
 * @returns Promise<HospitalShow>
 */
export function reqGetHospitalShow(id: string){
  return request.get<any, HospitalShow>(`/admin/hosp/hospital/show/${id}`);
}

/**
 * 获取医院科室的列表
 * @param hoscode 医院编号
 * @returns Promise<Departments>
 */
export function reqGetDepartments(hoscode: string){
  return request.get<any, Departments>(`/admin/hosp/department/${hoscode}`)
}

/**
 * 获取排班规则列表
 * @param param0 请求参数
 * @returns  Promise<ReqGetScheduleRuleResponse>
 */
export function reqGetHospitalScheduleRules({
  page,
  limit,
  hoscode,
  depcode
}: ReqGetScheduleRuleParams){
  return request.get<any, ReqGetScheduleRuleResponse>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`)
}

/**
 * 通过日期与科室的编号获得某一天的排班
 * @param param0 参数对象
 * @returns  Promise<HospitalScheduleResponse>
 */
export function reqGetHospitalSchedules({
  hoscode,
  depcode,
  workDate
}: ReqGetHospitaScheduleParams){
  return request.get<any, HospitalScheduleResponse>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`)
}